

package com.hazelcast.jet.function;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * A function that accepts a JDBC connection to the database, the total
 * parallelism and processor index as arguments and produces a result set.
 * This result set should return a part of the whole result set specific to
 * this processor.
 *
 * @since Jet 3.0
 */
@FunctionalInterface
public interface ToResultSetFunction extends Serializable {

    /**
     * Creates a result set which returns a part of the rows pertaining to the
     * given processor.
     *
     * @param connection  the JDBC connection
     * @param parallelism the total parallelism for the processor
     * @param index       the global processor index
     */
    ResultSet createResultSet(Connection connection, int parallelism, int index) throws SQLException;
}
